import smtplib, string, sys

FROMADDR = 'gurianov@geo-s.ru'        # Author is Donn Lee.
SMTPSERVER = 'www.loc'    # Put your own email server here.

def EmailOut(toaddrs, subj, msg):
   # SIMPLE FUNCTION THAT SENDS EMAIL.
   # toaddrs MUST be a python list of email addresses.

   # Convert list to string.
   s_toaddrs = string.join(toaddrs, ",")
   # Convert msg to smtp format.
   msg = """\
To: %s
From: %s
Subject: %s

%s
""" % (s_toaddrs, FROMADDR, subj, msg)
   try:
      server = smtplib.SMTP(SMTPSERVER)
      # If your mail server requires a username/login, you'll need the following line.
      #server.login('gurianov@geo-s.ru', 'gavr@geos')
      server.sendmail(FROMADDR, toaddrs, msg)
      server.quit()
   except:
      print "ERROR SENDING EMAIL! SMTP ERROR."
      sys.exit()
#    End of fn EmailOut().
 
toaddrs = ['79277078010@sms.mgsm.ru','alexey@gurianov.com']
subj = 'Travian!'
msg = """\
Hello """

# Send the email.
EmailOut(toaddrs, subj, msg)